﻿@{
    ViewBag.Title = "Home";

    var posts = new Sap.Repositories.PostRepository(new Sap.Contexts.DatabaseContext());
}

@foreach (var post in posts.GetAll().OrderByDescending(p => p.Id))
{
    <div class="blog-post">
        <div class="blog-header">
            <h2>@Html.ActionLink(post.Title, "", "")</h2>
            <p>Posted @post.Date.ToString("MMMM dd, yyyy") by @Html.ActionLink(post.User.Username, "", ""). 
                Filled under @Html.ActionLink(post.Category.Name, "", "").</p>
        </div>
        <div class="blog-content">
            <p>@post.Content</p>
        </div>
    </div>
}